//
//  JuStruct.swift
//  JuSwift
//
//  Created by Juvid on 2018/5/8.
//  Copyright © 2018年 Juvid. All rights reserved.
//

import UIKit

class JuMuCls: NSObject {
    func juStart() {
        let juEnum = JuEnum.first
//        JuEnum.juStart()
        print(juEnum.juStart())
        var juStruct = JuStruct.init()
        juStruct.height = 10
        juStruct.width = 20
        print(juStruct.juStart())
        _ = Point.ones
        let point = Point(x: 1, y: 2)
    }
}

enum JuEnum : String {
    case first = "first"
    case second = "second"
    func juStart() -> String {
        switch self {
        case .first:
            return "first"
        default:
            return "second"
        }
    }
}

struct JuStruct {
    var width = 0
    var height = 0
    func juStart() -> String {
        return "this width is \(width) height \(height)"
    }


}

struct Point {
    let x: Double
    let y: Double
    var z: Double = 0
//    mutating防止直接修改属性的值，编译器报错。
    mutating func movePoint(a: Double) {
        self.z += a
    }
    // 存储属性
    static let zero = Point(x: 0, y: 0)

    // 计算属性
    static var ones: [Point] {
        return [
            Point(x: 1, y: 1),
            Point(x: -1, y: 1),
            Point(x: 1, y: -1),
            Point(x: -1, y: -1)
        ]
    }

}


